package com.example.venue_reservation_service.controller;

import com.example.venue_reservation_service.domain.Slot;
import com.example.venue_reservation_service.dto.PageDTO;
import com.example.venue_reservation_service.dto.SQueryDTO;
import com.example.venue_reservation_service.dto.SlotDTO;
import com.example.venue_reservation_service.dto.UserDTO;
import com.example.venue_reservation_service.service.SlotService;
import com.example.venue_reservation_service.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/slot")
@Api("禁用操作管理")
@CrossOrigin
public class SlotController {

    @Resource
    private SlotService slotService;

    @ApiOperation("查看场地的状态")
    @PostMapping("status")
    public Result status(@RequestBody SQueryDTO dto){
        return slotService.getStatus(dto);
    }

    @ApiOperation("移除禁用信息")
    @GetMapping("/remove")
    public Result remove(@RequestParam("slotId") Integer slotId,
                         @RequestParam("userId") Integer userId){
        return slotService.delSlot(slotId, userId);
    }

    @ApiOperation("分页查询场地禁用记录")
    @PostMapping("/page")
    public Result page(@RequestBody PageDTO dto){
        return slotService.pageSlots(dto);
    }

    @ApiOperation("管理员查看管理的场地的禁用时间段")
    @PostMapping("/query")
    public Result query(@RequestBody UserDTO dto){
        return slotService.querySlots(dto);
    }

    @ApiOperation("查询某禁用时间段下的可用场地信息")
    @GetMapping("/venue")
    public Result venue(@RequestParam("id")Integer slotId){
        return slotService.slotVenues(slotId);
    }

    @ApiOperation("超级管理员添加禁用时间段")
    @PostMapping("/add")
    public Result add(@RequestBody Slot slot){
        return slotService.createSlot(slot);
    }

    @ApiOperation("超级管理员设置禁用场地")
    @PostMapping("/set")
    public Result set(@RequestParam("ids") List<Integer> venueIds,
                      @RequestParam("slotId") Integer slotId){
        return slotService.setSlots(venueIds, slotId);
    }

    @ApiOperation("查询某禁用时间段下的已添加场地信息")
    @GetMapping("/inquire")
    public Result inquire(@RequestParam("slotId") Integer id){
        return slotService.inquireMsg(id);
    }

    @ApiOperation("移除某时间段下的场地数据")
    @PostMapping("/del")
    public Result del(@RequestParam("venueId") Integer vId,
                      @RequestParam("slotId") Integer sId){
        return slotService.removeSlot(vId, sId);
    }


}
